# vim: ft=python:
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from buildbot.changes.filter import ChangeFilter
from buildbot.process.properties import WithProperties
from buildbot.scheduler import Dependent
from buildbot.scheduler import Nightly
from buildbot.scheduler import Periodic
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable
from buildbot.status.mail import MailNotifier

from common import chromium_utils

# These modules come from scripts/master, which must be in the PYTHONPATH.
from master import build_utils
from master import chromium_notifier
from master import failures_notifier
from master import master_config
from master import master_utils
from master import slaves_list
from master import gitiles_poller

from master.factory import annotator_factory
from master.factory import remote_run_factory

# These modules come from scripts/common, which must be in the PYTHONPATH.
import config
import master_site_config

ActiveMaster = master_site_config.ChromiumFYI

STATUS_PUSH = False

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
c['status'] = []

# Force merging of requests.
c['mergeRequests'] = lambda *args, **kwargs: True

config.DatabaseSetup(c)

####### CHANGESOURCES

# Polls config.Master.trunk_url for changes
chromium_repo_url = config.Master.git_server_url + '/chromium/src'
trunk_poller = gitiles_poller.GitilesPoller(chromium_repo_url,
                                            project='chromium')

c['change_source'] = [trunk_poller]

# Number of machines to shard ash browser_tests over.
ASH_SHARDS = 2

####### SCHEDULERS

## configure the Schedulers

# Main scheduler for all changes in trunk.
s_chromium = Scheduler(
    name='chromium',
    treeStableTimer=60,
    change_filter=ChangeFilter(project='chromium', branch='master'),
    builderNames=['Chromium Windows Analyze',
                  # The bots need a short name to work around crbug.com/399990.
                  'CrWinGoma',
                  'CrWinGoma(dll)',  # not (shared) cause crbug.com/399990
                  'CrWinGoma(loc)',  # not (LocalOutputCache) crbug.com/399990
                  'CrWin7Goma',
                  'CrWin7Goma(dll)',  # not (shared) cause crbug.com/399990
                  'CrWin7Goma(dbg)',
                  'CrWin7Goma(clbr)',  # not (clobber) cause crbug.com/399990
                  'CrWinClangGoma',
                  'CrWinClang',
                  'CrWinClang(dbg)',
                  'CrWinClang(shared)',
                  'CrWinClang64',
                  'CrWinClang64(dbg)',
                  'CrWinClang64(dll)',  # not (shared) cause crbug.com/399990
                  'CrWinClangLLD',
                  'CrWinClngLLDdbg',
                  'CrWinClangLLD64',
                  'CrWinClngLLD64dbg',  # not (dbg) cause crbug.com/399990
                  'CrWinAsan',
                  'CrWinAsanCov',
                  'ClangToTLinux',
                  'ClangToTLinux (dbg)',
                  'ClangToTLinuxASan',
                  'ClangToTLinuxASanLibfuzzer',
                  'ClangToTLinuxLLD',
                  'ClangToTLinuxUBSanVptr',
                  'ClangToTAndroidASan',
                  'ClangToTAndroid (dbg)',
                  'ClangToTAndroid',
                  'ClangToTAndroid64',
                  'ClangToTAndroid x64',
                  'ClangToTMac',
                  'ClangToTMac (dbg)',
                  'ClangToTMacASan',
                  'ClangToTiOS',
                  'ClangToTWin',
                  'ClangToTWin(dbg)',
                  'ClangToTWin(dll)',  # not (shared) cause crbug.com/399990
                  'ClangToTWin64',
                  'ClangToTWin64(dbg)',
                  'ClangToTWin64(dll)',  # not (shared) cause crbug.com/399990
                  'CrWinAsan(dll)',  # not (asan/shared) cause crbug.com/399990
                  'Chromium Win PGO Builder',
                  'Chromium Win x64 PGO Builder',
                  'Android Builder (dbg)',
                  'Android Builder Goma Canary (dbg)',
                  'Chromium Linux Goma Canary',
                  'Chromium Linux Goma Canary (clobber)',
                  'Chromium Linux Goma Canary LocalOutputCache',
                  'Chromium Mac 10.9 Goma Canary',
                  'Chromium Mac 10.9 Goma Canary (dbg)',
                  'Chromium Mac 10.9 Goma Canary (clobber)',
                  'Chromium Mac 10.9 Goma Canary (dbg)(clobber)',
                  'Chromium Mac Goma Canary LocalOutputCache',
                  'Chromium Mac 10.10 MacViews',
                  'Chromium Mac 10.11',
                  'Chromium Mac 10.11 Force Mac Toolchain',
                  'Linux ARM',
                  'Headless Linux (dbg)',
                  'Ozone Linux',
                  'Fuchsia',
                  'Site Isolation Android',
                  'Site Isolation Linux',
                  'Site Isolation Win',
                  'Browser Side Navigation Linux',
                  'Closure Compilation Linux',
                  'CFI Linux',
                  'CFI Linux Full',
                  'CFI Linux ToT',
                  'CFI Linux CF',
                  'CFI ThinLTO Linux ToT',
                  'LTO Linux',
                  'LTO Linux Perf',
                  'ThinLTO Linux ToT',
                  'UBSanVptr Linux',
                  'Win 10 Fast Ring',
                  'Afl Upload Linux ASan',
                  'Libfuzzer Upload Linux ASan',
                  'Libfuzzer Upload Linux ASan Debug',
                  'Libfuzzer Upload Linux MSan',
                  'Libfuzzer Upload Linux UBSan',
                  'Libfuzzer Upload Mac ASan',
                  'WebKit Linux - RandomOrder',
                  'WebKit Mac - RandomOrder',
                  'WebKit Win - RandomOrder',
                  'Linux remote_run Builder',
                  'EarlGreyiOS',
                  'GomaCanaryiOS',
                  'ios-simulator',
                  'ios-simulator-cronet',
                  'Mojo ChromiumOS',
                  'Mojo Linux',
                  'Mojo Windows',
                  'Android deterministic',
                  'Mac deterministic',
                  'Windows deterministic',
                  'Windows Clang deterministic',
                  'Android deterministic (dbg)',
                  'Linux deterministic (dbg)',
                  'Mac deterministic (dbg)',
                  'Chromium DevTools Linux',
                  'Linux Clang Analyzer',
                  ])

# Triggerable scheduler for Android Builder
s_chromium_android_dbg = Triggerable(
    name='android_dbg',
    builderNames=['Android ChromeDriver Tests (dbg)',
                  'Android Remoting Tests',
                  'Android VR Tests',])

s_android_find_annotated_test = Nightly(
    name='android_find_annotated_test',
    branch='master',
    minute=0,
    hour=range(0,24,3),
    builderNames=['Android Find Annotated Test'])

# Triggerable schedulers for clang/win bots
s_win_clang = Triggerable(
    name='cr_win_clang', builderNames=['CrWinClang tester'])
s_win_clang_dbg = Triggerable(
    name='cr_win_clang_dbg', builderNames=['CrWinClang(dbg) tester'])
s_win_clang_shared = Triggerable(
    name='cr_win_clang_shared', builderNames=['CrWinClang(shared) tester'])
s_win_clang_64 = Triggerable(
    name='cr_win_clang_64',
    builderNames=['CrWinClang64 tester'])
s_win_clang_64_dbg = Triggerable(
    name='cr_win_clang_64_dbg',
    builderNames=['CrWinClang64(dbg) tester'])
s_win_clang_64_shared = Triggerable(
    name='cr_win_clang_64_shared',
    builderNames=['CrWinClang64(dll) tester'])
s_win_clang_lld = Triggerable(
    name='cr_win_clang_lld', builderNames=['CrWinClangLLD tester'])
s_win_clang_lld_dbg = Triggerable(
    name='cr_win_clang_lld_dbg', builderNames=['CrWinClngLLDdbg tester'])
s_win_clang_lld64 = Triggerable(
    name='cr_win_clang_lld64', builderNames=['CrWinClangLLD64 tester'])
s_win_clang_lld64_dbg = Triggerable(
    name='cr_win_clang_lld64_dbg', builderNames=['CrWinClngLLD64dbg tester'])
s_win_clang_asan = Triggerable(
    name='cr_win_clang_asan', builderNames=['CrWinAsan tester'])
s_win_clang_asan_shared = Triggerable(
    name='cr_win_clang_asan_shared', builderNames=['CrWinAsan(dll) tester'])
s_win_clang_asan_coverage = Triggerable(
    name='cr_win_clang_asan_coverage', builderNames=['CrWinAsanCov tester'])

# Triggerable schedulers for Clang ToT bots.
s_clang_tot_linux = Triggerable(
    name='clang_tot_linux', builderNames=['ClangToTLinux tester'])
s_clang_tot_linux_asan = Triggerable(
    name='clang_tot_linux_asan', builderNames=['ClangToTLinuxASan tester'])
s_clang_tot_linux_asan_libfuzzer = Triggerable(
    name='clang_tot_linux_asan_libfuzzer',
    builderNames=['ClangToTLinuxASanLibfuzzer'])
s_clang_tot_linux_lld = Triggerable(
    name='clang_tot_linux_lld', builderNames=['ClangToTLinuxLLD tester'])
s_clang_tot_linux_ubsan_vptr = Triggerable(
    name='clang_tot_linux_ubsan_vptr', builderNames=['ClangToTLinuxUBSanVptr tester'])
s_clang_tot_mac = Triggerable(
    name='clang_tot_mac', builderNames=['ClangToTMac tester'])
s_clang_tot_mac_asan = Triggerable(
    name='clang_tot_mac_asan', builderNames=['ClangToTMacASan tester'])
s_clang_tot_win = Triggerable(
    name='clang_tot_win', builderNames=['ClangToTWin tester'])
s_clang_tot_win_dbg = Triggerable(
    name='clang_tot_win_dbg', builderNames=['ClangToTWin(dbg) tester'])
s_clang_tot_win_dll = Triggerable(
    name='clang_tot_win_dll', builderNames=['ClangToTWin(dll) tester'])
s_clang_tot_win64 = Triggerable(
    name='clang_tot_win64', builderNames=['ClangToTWin64 tester'])
s_clang_tot_win64_dbg = Triggerable(
    name='clang_tot_win64_dbg', builderNames=['ClangToTWin64(dbg) tester'])
s_clang_tot_win64_dll = Triggerable(
    name='clang_tot_win64_dll', builderNames=['ClangToTWin64(dll) tester'])

c['schedulers'] = [s_chromium,
                   s_chromium_android_dbg,
                   s_android_find_annotated_test,
                   s_win_clang,
                   s_win_clang_dbg,
                   s_win_clang_shared,
                   s_win_clang_64,
                   s_win_clang_64_dbg,
                   s_win_clang_64_shared,
                   s_win_clang_lld,
                   s_win_clang_lld_dbg,
                   s_win_clang_lld64,
                   s_win_clang_lld64_dbg,
                   s_win_clang_asan,
                   s_win_clang_asan_shared,
                   s_win_clang_asan_coverage,
                   s_clang_tot_linux,
                   s_clang_tot_linux_asan,
                   s_clang_tot_linux_asan_libfuzzer,
                   s_clang_tot_linux_lld,
                   s_clang_tot_linux_ubsan_vptr,
                   s_clang_tot_mac,
                   s_clang_tot_mac_asan,
                   s_clang_tot_win,
                   s_clang_tot_win_dbg,
                   s_clang_tot_win_dll,
                   s_clang_tot_win64,
                   s_clang_tot_win64_dbg,
                   s_clang_tot_win64_dll,
]

####### BUILDERS

# buildbot/process/factory.py provides several BuildFactory classes you can
# start with, which implement build processes for common targets (GNU
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
# base class, and is configured with a series of BuildSteps. When the build
# is run, the appropriate buildslave is told to execute each Step in turn.

# the first BuildStep is typically responsible for obtaining a copy of the
# sources. There are source-obtaining Steps in buildbot/process/step.py for
# CVS, SVN, and others.

builders = []

# ----------------------------------------------------------------------------
# FACTORIES

chromium_rel_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'Chromium FYI Builder')

chromium_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'Chromium FYI Builder (dbg)')

chromium_android_fyi_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-fyi-archive', 'chromium.fyi/Android Builder (dbg)')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.
f_chromium_win_pgo_builder = \
    annotator_factory.AnnotatorFactory().BaseFactory(recipe='chromium_pgo',
                                                     timeout=24000)

f_chromium_win_x64_pgo_builder = \
    annotator_factory.AnnotatorFactory().BaseFactory(recipe='chromium_pgo',
                                                     timeout=24000)

f_win_analyze = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='win_analyze')

def without(these, notthese):
  return [x for x in these if x not in notthese]

tests_win_1 = ['base_unittests',
               'cacheinvalidation_unittests',
               'chrome_elf_unittests',
               'components_unittests',
               'courgette_unittests',
               'crypto_unittests',
               'device_unittests',
               'extensions_unittests',
               'gcm_unit_tests',
               'google_apis_unittests',
               'gpu',
               'installer',
               'jingle',
               'media',
               'net',
               'ppapi_unittests',
               'printing',
               'remoting',
               'sandbox',
               'unit',
               'url_unittests',
]
tests_win_2 = ['browser_tests',
               'content_browsertests']

win_x64_tests = [
  'base_unittests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver_unittests',
  'components_unittests',
  'content_browsertests',
  'courgette_unittests',
  'crypto_unittests',
  'gcm_unit_tests',
  'gpu',
  'installer',
  'interactive_ui_tests',
  'jingle',
  'media',
  'nacl_integration',
  'net',
  'ppapi_unittests',
  'printing',
  'remoting',
  'sandbox',
  'unit',
  'url_unittests',

  # These are long, so do them last
  'browser_tests',
  'sync_integration',
]

f_chromium_dbg_android_mips_builder = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='android/builder')

f_chromium_dbg_android_x86_builder = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='android/builder')

def m_remote_run(recipe, **kwargs):
  return remote_run_factory.RemoteRunFactory(
      active_master=ActiveMaster,
      repository='https://chromium.googlesource.com/chromium/tools/build.git',
      recipe=recipe,
      factory_properties={'path_config': 'kitchen'},
      **kwargs)

f_chromium_mac_1010 = m_remote_run('chromium')

f_chromium_mac_1010_mac_views = m_remote_run('chromium')

f_chromium_mac_1011 = m_remote_run('chromium')

f_chromium_mac_1011_force_mac_toolchain = m_remote_run('chromium')


# ----------------------------------------------------------------------------
# BUILDER DEFINITIONS

# The 'builders' list defines the Builders. Each one is configured with a
# dictionary, using the following keys:
#  name (required): the name used to describe this bilder
#  slavename (required): which slave to use, must appear in c['slaves']
#  builddir (optional): which subdirectory to run the builder in
#  factory (required): a BuildFactory to define how the build is run
#  periodicBuildTime (optional): if set, force a build every N seconds
#  category (optional): it is not used in the normal 'buildbot' meaning. It is
#                       used by gatekeeper to determine which steps it should
#                       look for to close the tree.
#

m_annotator = annotator_factory.AnnotatorFactory()

b_chromium_win_analyze = {'name': 'Chromium Windows Analyze',
  'builddir': 'Chromium_Windows_Analyze',
  'factory': f_win_analyze,
  'auto_reboot': False,
}

b_chromium_win_pgo_builder = {
  'name': 'Chromium Win PGO Builder',
  'builddir': 'chromium-win-pgo-builder',
  'factory': f_chromium_win_pgo_builder,
  'category': 'windows',
  'auto_reboot': True,
}

b_chromium_win_x64_pgo_builder = {
  'name': 'Chromium Win x64 PGO Builder',
  'builddir': 'chromium-win-x64-pgo-builder',
  'factory': f_chromium_win_x64_pgo_builder,
  'category': 'windows',
  'auto_reboot': True,
}

b_chromium_win_goma = {
  'name': 'CrWinGoma',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win_goma_shared = {
  'name': 'CrWinGoma(dll)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win_goma_local_output_cache = {
  'name': 'CrWinGoma(loc)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win7_goma = {
  'name': 'CrWin7Goma',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win7_goma_shared = {
  'name': 'CrWin7Goma(dll)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win7_goma_dbg = {
  'name': 'CrWin7Goma(dbg)',
  'factory': m_remote_run('chromium', timeout=3600),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win7_goma_clobber = {
  'name': 'CrWin7Goma(clbr)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win_clang_goma = {
  'name': 'CrWinClangGoma',
  'factory': m_remote_run('chromium', timeout=3000),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_win_clang = {
  'name': 'CrWinClang',
  'factory': m_remote_run('chromium', triggers=['cr_win_clang']),
  'category': 'win clang',
  'auto_reboot': True,
}

b_chromium_win_clang_tester = {
  'name': 'CrWinClang tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_dbg = {
  'name': 'CrWinClang(dbg)',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_dbg']),
  'category': 'win clang',
  'auto_reboot': True,
}
b_chromium_win_clang_dbg_tester = {
  'name': 'CrWinClang(dbg) tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_shared = {
  'name': 'CrWinClang(shared)',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_shared']),
  'category': 'win clang',
  'auto_reboot': True,
}
b_chromium_win_clang_shared_tester = {
  'name': 'CrWinClang(shared) tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64 = {
  'name': 'CrWinClang64',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_64']),
  'category': 'win clang',
  'auto_reboot': True,
}
b_chromium_win_clang_64_tester = {
  'name': 'CrWinClang64 tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64_dbg = {
  'name': 'CrWinClang64(dbg)',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_64_dbg']),
  'category': 'win clang',
  'auto_reboot': True,
}
b_chromium_win_clang_64_dbg_tester = {
  'name': 'CrWinClang64(dbg) tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64_shared = {
  'name': 'CrWinClang64(dll)',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_64_shared']),
  'category': 'win clang',
  'auto_reboot': True,
}
b_chromium_win_clang_64_shared_tester = {
  'name': 'CrWinClang64(dll) tester',
  'factory': m_remote_run('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_lld = {
  'name': 'CrWinClangLLD',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_lld']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_lld_tester = {
  'name': 'CrWinClangLLD tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_lld_dbg = {
  'name': 'CrWinClngLLDdbg',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_lld_dbg']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_lld_dbg_tester = {
  'name': 'CrWinClngLLDdbg tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_lld64 = {
  'name': 'CrWinClangLLD64',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_lld64']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_lld64_tester = {
  'name': 'CrWinClangLLD64 tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_lld64_dbg = {
  'name': 'CrWinClngLLD64dbg',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_lld64_dbg']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_lld64_dbg_tester = {
  'name': 'CrWinClngLLD64dbg tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win_clang_asan = {
  'name': 'CrWinAsan',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_asan']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_asan_tester = {
  'name': 'CrWinAsan tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win_clang_asan_shared = {
  'name': 'CrWinAsan(dll)',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_asan_shared']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_asan_shared_tester = {
  'name': 'CrWinAsan(dll) tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win_clang_asan_coverage = {
  'name': 'CrWinAsanCov',
  'factory': m_remote_run(
      'chromium', triggers=['cr_win_clang_asan_coverage']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_chromium_win_clang_asan_coverage_tester = {
  'name': 'CrWinAsanCov tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux = {
  'name': 'ClangToTLinux',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_linux']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_tester = {
  'name': 'ClangToTLinux tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_dbg = {
  'name': 'ClangToTLinux (dbg)',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_asan = {
  'name': 'ClangToTLinuxASan',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_linux_asan']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_asan_tester = {
  'name': 'ClangToTLinuxASan tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_asan_libfuzzer = {
  'name': 'ClangToTLinuxASanLibfuzzer',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer_clang_tot'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_lld = {
  'name': 'ClangToTLinuxLLD',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_linux_lld']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_lld_tester = {
  'name': 'ClangToTLinuxLLD tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_ubsan_vptr = {
  'name': 'ClangToTLinuxUBSanVptr',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_linux_ubsan_vptr']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_ubsan_vptr_tester = {
  'name': 'ClangToTLinuxUBSanVptr tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_static_analyzer = {
  'name': 'Linux Clang Analyzer',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android_asan = {
  'name': 'ClangToTAndroidASan',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android_dbg = {
  'name': 'ClangToTAndroid (dbg)',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android = {
  'name': 'ClangToTAndroid',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android64 = {
  'name': 'ClangToTAndroid64',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android_x64 = {
  'name': 'ClangToTAndroid x64',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_mac = {
  'name': 'ClangToTMac',
  'factory': m_remote_run('chromium', triggers=['clang_tot_mac']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_mac_tester = {
  'name': 'ClangToTMac tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_mac_dbg = {
  'name': 'ClangToTMac (dbg)',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_mac_asan = {
  'name': 'ClangToTMacASan',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_mac_asan']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_mac_asan_tester = {
  'name': 'ClangToTMacASan tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_ios = {
  'name': 'ClangToTiOS',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_win = {
  'name': 'ClangToTWin',
  'factory': m_remote_run('chromium', triggers=['clang_tot_win']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win_tester = {
  'name': 'ClangToTWin tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dbg = {
  'name': 'ClangToTWin(dbg)',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_win_dbg']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win_dbg_tester = {
  'name': 'ClangToTWin(dbg) tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dll = {
  'name': 'ClangToTWin(dll)',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_win_dll']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win_dll_tester = {
  'name': 'ClangToTWin(dll) tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64 = {
  'name': 'ClangToTWin64',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_win64']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win64_tester = {
  'name': 'ClangToTWin64 tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dbg = {
  'name': 'ClangToTWin64(dbg)',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_win64_dbg']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win64_dbg_tester = {
  'name': 'ClangToTWin64(dbg) tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dll = {
  'name': 'ClangToTWin64(dll)',
  'factory': m_remote_run(
      'chromium', triggers=['clang_tot_win64_dll']),
  'category': 'clang tot',
  'auto_reboot': True,
}
b_clang_tot_win64_dll_tester = {
  'name': 'ClangToTWin64(dll) tester',
  'factory': m_remote_run('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_dbg_android_builder = {
  'name': 'Android Builder (dbg)',
  'factory': m_remote_run(
      recipe='chromium', triggers=['android_dbg']),
  'category': 'android_builder',
}

b_chromium_dbg_android_builder_goma_canary = {
  'name': 'Android Builder Goma Canary (dbg)',
  'factory': m_remote_run(recipe='chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_rel_android_remoting_tests = {
  'name': 'Android Remoting Tests',
  'factory': m_remote_run('chromium'),
  'category': 'android_tests',
}

b_chromium_rel_android_find_annotated_test = {
  'name': 'Android Find Annotated Test',
  'factory': m_remote_run('chromium'),
  'category': 'android_tests',
}

b_chromium_dbg_android_chromedriver_tests = {
  'name': 'Android ChromeDriver Tests (dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='chromedriver'),
  'category': 'android_tests',
}

b_chromium_dbg_android_vr_tests = {
  'name': 'Android VR Tests',
  'factory': m_remote_run('chromium'),
  'category': 'android_tests',
}

b_chromium_linux_goma_canary = {
  'name': 'Chromium Linux Goma Canary',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_linux_goma_canary_clobber = {
  'name': 'Chromium Linux Goma Canary (clobber)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_linux_goma_canary_local_output_cache = {
  'name': 'Chromium Linux Goma Canary LocalOutputCache',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_106_goma_canary = {
  'name': 'Chromium Mac 10.9 Goma Canary',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_107_goma_canary = {
  'name': 'Chromium Mac 10.9 Goma Canary (dbg)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_106_goma_canary_clobber = {
  'name': 'Chromium Mac 10.9 Goma Canary (clobber)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_107_goma_canary_clobber = {
  'name': 'Chromium Mac 10.9 Goma Canary (dbg)(clobber)',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_goma_canary_local_output_cache = {
  'name': 'Chromium Mac Goma Canary LocalOutputCache',
  'factory': m_remote_run('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_1010_mac_views = {
  'name': 'Chromium Mac 10.10 MacViews',
  'factory': f_chromium_mac_1010_mac_views,
  'auto_reboot': True,
}

b_chromium_mac_1011 = {
  'name': 'Chromium Mac 10.11',
  'factory': f_chromium_mac_1011,
  'auto_reboot': True,
}

b_chromium_mac_1011_force_mac_toolchain = {
  'name': 'Chromium Mac 10.11 Force Mac Toolchain',
  'factory': f_chromium_mac_1011_force_mac_toolchain,
  'auto_reboot': True,
}

b_linux_arm = {
  'name': 'Linux ARM',
  'factory': m_remote_run('chromium'),
  'category': 'linux',
  'auto_reboot': False,
}

b_chromium_linux_webkit_randomorder = {
    'name': 'WebKit Linux - RandomOrder',
    'factory': m_remote_run('chromium'),
    'category': 'linux',
    'auto_reboot': True,
}
b_chromium_mac_webkit_randomorder = {
    'name': 'WebKit Mac - RandomOrder',
    'factory': m_remote_run('chromium'),
    'category': 'mac',
    'auto_reboot': True,
}
b_chromium_win_webkit_randomorder = {
    'name': 'WebKit Win - RandomOrder',
    'factory': m_remote_run('chromium'),
    'category': 'win10',
    'auto_reboot': True,
}

b_headless_linux = {
    'name': 'Headless Linux (dbg)',
    'factory': m_remote_run('chromium'),
    'category': 'linux',
}

b_chromium_ozone_linux = {
  'name': 'Ozone Linux',
  'factory': m_remote_run('chromium'),
  'category': 'linux',
  'auto_reboot': True,
}

b_chromium_fuchsia = {
  'name': 'Fuchsia',
  'factory': m_remote_run('chromium'),
  'category': 'linux',
  'auto_reboot': True,
}

b_chromium_site_isolation_android = {
  'name': 'Site Isolation Android',
  'factory': m_remote_run('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_site_isolation_linux = {
  'name': 'Site Isolation Linux',
  'factory': m_remote_run('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_site_isolation_win = {
  'name': 'Site Isolation Win',
  'factory': m_remote_run('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_browser_side_navigation_linux = {
  'name': 'Browser Side Navigation Linux',
  'factory': m_remote_run('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_closure_compilation_linux = {
  'name': 'Closure Compilation Linux',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='closure_compilation'),
  'category': 'closure_compilation',
  'auto_reboot': True,
}

b_chromium_cfi_linux = {
  'name': 'CFI Linux',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_chromium_cfi_linux_full = {
  'name': 'CFI Linux Full',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_chromium_cfi_linux_tot = {
  'name': 'CFI Linux ToT',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_chromium_cfi_linux_cf = {
  'name': 'CFI Linux CF',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_chromium_cfi_thin_lto_linux_tot = {
  'name': 'CFI ThinLTO Linux ToT',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_chromium_lto_linux = {
  'name': 'LTO Linux',
  'factory': m_remote_run('chromium', timeout=12000),
  'builddir': 'google-chrome-lto-linux_64',
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_chromium_lto_linux_perf = {
  'name': 'LTO Linux Perf',
  'factory': m_remote_run('chromium', timeout=12000),
  'builddir': 'google-chrome-lto-perf-linux_64',
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_chromium_thin_lto_linux_tot = {
  'name': 'ThinLTO Linux ToT',
  'factory': m_remote_run('chromium', timeout=12000),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_chromium_ubsan_vptr_linux = {
  'name': 'UBSanVptr Linux',
  'factory': m_remote_run('chromium', timeout=6000),
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

b_win_10_fast_ring = {
  'name': 'Win 10 Fast Ring',
  'factory': m_remote_run('chromium'),
  'category': 'win10',
  'auto_reboot': True,
}

b_chromium_afl_upload_linux_asan = {
  'name': 'Afl Upload Linux ASan',
  'factory': m_annotator.BaseFactory('chromium_afl',
                                     timeout=24000),
  'category': 'chromium_afl',
  'auto_reboot': True,
}

b_chromium_libfuzzer_upload_linux_asan = {
  'name': 'Libfuzzer Upload Linux ASan',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer',
                                     timeout=24000),
  'category': 'chromium_libfuzzer',
  'auto_reboot': True,
}

b_chromium_libfuzzer_upload_linux_asan_debug = {
  'name': 'Libfuzzer Upload Linux ASan Debug',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer',
                                     timeout=24000),
  'category': 'chromium_libfuzzer',
  'auto_reboot': True,
}

b_chromium_libfuzzer_upload_linux_msan = {
  'name': 'Libfuzzer Upload Linux MSan',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer',
                                     timeout=24000),
  'category': 'chromium_libfuzzer',
  'auto_reboot': True,
}

b_chromium_libfuzzer_upload_linux_ubsan = {
  'name': 'Libfuzzer Upload Linux UBSan',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer',
                                     timeout=24000),
  'category': 'chromium_libfuzzer',
  'auto_reboot': True,
}

b_chromium_libfuzzer_upload_mac_asan = {
  'name': 'Libfuzzer Upload Mac ASan',
  'factory': m_annotator.BaseFactory('chromium_libfuzzer',
                                     timeout=24000),
  'category': 'chromium_libfuzzer',
  'auto_reboot': True,
}

b_earlgrey_ios = {
  'name': 'EarlGreyiOS',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'earlgrey',
  'auto_reboot': True,
}

b_gomacanary_ios = {
  'name': 'GomaCanaryiOS',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'goma',
  'auto_reboot': True,
}

b_simulator_ios = {
  'name': 'ios-simulator',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'iOS',
  'auto_reboot': True,
}

b_simulator_ios_cronet = {
  'name': 'ios-simulator-cronet',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'cronet',
  'auto_reboot': True,
}

b_mojo_chromiumos = {
  'name': 'Mojo ChromiumOS',
  'factory': m_remote_run('chromium'),
  'category': 'mojo',
  'auto_reboot': True,
}

b_mojo_linux = {
  'name': 'Mojo Linux',
  'factory': m_remote_run('chromium'),
  'category': 'mojo',
  'auto_reboot': True,
}

b_mojo_windows = {
  'name': 'Mojo Windows',
  'factory': m_remote_run('chromium'),
  'category': 'mojo',
  'auto_reboot': True,
}

b_chromium_devtools_linux = {
  'name': 'Chromium DevTools Linux',
  'factory': m_annotator.BaseFactory(recipe='devtools'),
  'category': 'devtools',
  'auto_reboot': True,
}

def DeterministicBuilder(platform, debug=False):
  suffix = ''
  configuration = 'Release'
  if debug:
    suffix = ' (dbg)'
    configuration = 'Debug'
  return  {
      'name': '%s deterministic%s' % (platform, suffix),
      # Work around an issue with NaCl build.
      'slavebuilddir': 'chr',
      'factory': annotator_factory.AnnotatorFactory().BaseFactory(
          'swarming/deterministic_build',
          factory_properties = {
            'configuration': configuration,
          }),
      # Auto-reboot:
      # - On windows to try to clear up TEMP fill up issues.
      # - On OSX due to fork: Resource temporarily unavailable
      'auto_reboot': True,
      'category': 'deterministic',
    }

b_android_deterministic_build = DeterministicBuilder('Android')
b_mac_deterministic_build = DeterministicBuilder('Mac')
b_windows_deterministic_build = DeterministicBuilder('Windows')
b_windows_clang_deterministic_build = DeterministicBuilder('Windows Clang')
b_android_deterministic_dbg_build = DeterministicBuilder('Android', debug=True)
b_linux_deterministic_dbg_build = DeterministicBuilder('Linux', debug=True)
b_mac_deterministic_dbg_build = DeterministicBuilder('Mac', debug=True)

c['builders'] = [
  # Windows release
  b_chromium_win_goma,
  b_chromium_win_goma_shared,
  b_chromium_win_goma_local_output_cache,
  b_chromium_win7_goma,
  b_chromium_win7_goma_shared,
  b_chromium_win7_goma_dbg,
  b_chromium_win7_goma_clobber,
  b_chromium_win_clang_goma,
  b_chromium_win_clang,
  b_chromium_win_clang_tester,
  b_chromium_win_clang_dbg,
  b_chromium_win_clang_dbg_tester,
  b_chromium_win_clang_shared,
  b_chromium_win_clang_shared_tester,
  b_chromium_win_clang_64,
  b_chromium_win_clang_64_tester,
  b_chromium_win_clang_64_dbg,
  b_chromium_win_clang_64_dbg_tester,
  b_chromium_win_clang_64_shared,
  b_chromium_win_clang_64_shared_tester,
  b_chromium_win_pgo_builder,
  b_chromium_win_x64_pgo_builder,

  # Mac BuilderTesters
  b_chromium_mac_106_goma_canary,
  b_chromium_mac_107_goma_canary,
  b_chromium_mac_106_goma_canary_clobber,
  b_chromium_mac_107_goma_canary_clobber,
  b_chromium_mac_goma_canary_local_output_cache,
  b_chromium_mac_1010_mac_views,
  b_chromium_mac_1011,
  b_chromium_mac_1011_force_mac_toolchain,

  # Windows /Analyze builder
  b_chromium_win_analyze,

  # Linux BuilderTesters
  b_chromium_linux_goma_canary,
  b_chromium_linux_goma_canary_clobber,
  b_chromium_linux_goma_canary_local_output_cache,

  # Linux ARM
  b_linux_arm,

  # Android
  b_chromium_dbg_android_builder,
  b_chromium_dbg_android_builder_goma_canary,
  b_chromium_rel_android_remoting_tests,
  b_chromium_rel_android_find_annotated_test,
  b_chromium_dbg_android_vr_tests,

  b_chromium_dbg_android_chromedriver_tests,

  # Sanitizers
  b_chromium_afl_upload_linux_asan,
  b_chromium_libfuzzer_upload_linux_asan,
  b_chromium_libfuzzer_upload_linux_asan_debug,
  b_chromium_libfuzzer_upload_linux_msan,
  b_chromium_libfuzzer_upload_linux_ubsan,
  b_chromium_libfuzzer_upload_mac_asan,

  # Headles BuilderTester
  b_headless_linux,

  # Desktop linux with ozone
  b_chromium_ozone_linux,

  # Fuchsia
  b_chromium_fuchsia,

  # Site Isolation
  b_chromium_site_isolation_android,
  b_chromium_site_isolation_linux,
  b_chromium_site_isolation_win,
  b_chromium_browser_side_navigation_linux,

  # Closure Compilation
  b_chromium_closure_compilation_linux,

  # Clang ToT bots.
  b_clang_tot_linux,
  b_clang_tot_linux_tester,
  b_clang_tot_linux_dbg,
  b_clang_tot_linux_asan,
  b_clang_tot_linux_asan_tester,
  b_clang_tot_linux_asan_libfuzzer,
  b_clang_tot_linux_lld,
  b_clang_tot_linux_lld_tester,
  b_clang_tot_linux_ubsan_vptr,
  b_clang_tot_linux_ubsan_vptr_tester,
  b_clang_tot_android_asan,
  b_clang_tot_android_dbg,
  b_clang_tot_android,
  b_clang_tot_android64,
  b_clang_tot_android_x64,
  b_clang_tot_mac,
  b_clang_tot_mac_tester,
  b_clang_tot_mac_dbg,
  b_clang_tot_mac_asan,
  b_clang_tot_mac_asan_tester,
  b_clang_tot_ios,
  b_clang_tot_win,
  b_clang_tot_win_tester,
  b_clang_tot_win_dbg,
  b_clang_tot_win_dbg_tester,
  b_clang_tot_win_dll,
  b_clang_tot_win_dll_tester,
  b_clang_tot_win64,
  b_clang_tot_win64_tester,
  b_clang_tot_win64_dbg,
  b_clang_tot_win64_dbg_tester,
  b_clang_tot_win64_dll,
  b_clang_tot_win64_dll_tester,
  b_chromium_win_clang_lld,
  b_chromium_win_clang_lld_tester,
  b_chromium_win_clang_lld_dbg,
  b_chromium_win_clang_lld_dbg_tester,
  b_chromium_win_clang_lld64,
  b_chromium_win_clang_lld64_tester,
  b_chromium_win_clang_lld64_dbg,
  b_chromium_win_clang_lld64_dbg_tester,
  b_chromium_win_clang_asan,
  b_chromium_win_clang_asan_tester,
  b_chromium_win_clang_asan_shared,
  b_chromium_win_clang_asan_shared_tester,
  b_chromium_win_clang_asan_coverage,
  b_chromium_win_clang_asan_coverage_tester,
  b_clang_tot_linux_static_analyzer,

  # Control flow integrity.
  b_chromium_cfi_linux,
  b_chromium_cfi_linux_full,
  b_chromium_cfi_linux_tot,
  b_chromium_cfi_linux_cf,
  b_chromium_cfi_thin_lto_linux_tot,

  # LTO
  b_chromium_lto_linux,
  b_chromium_lto_linux_perf,

  # ThinLTO
  b_chromium_thin_lto_linux_tot,

  # UBSan Vptr
  b_chromium_ubsan_vptr_linux,

  # Windows 10 Fast Ring (early releases of Win 10).
  b_win_10_fast_ring,

  # WebKit Linux - layout tests in random order
  b_chromium_linux_webkit_randomorder,
  b_chromium_mac_webkit_randomorder,
  b_chromium_win_webkit_randomorder,

  # EarlGrey bot
  b_earlgrey_ios,

  # Goma canary
  b_gomacanary_ios,

  # ios-simulator
  b_simulator_ios,

  # ios-simulator-cronet
  b_simulator_ios_cronet,

  # Mojo bots.
  b_mojo_chromiumos,
  b_mojo_linux,
  b_mojo_windows,

  # Deterministic build bot
  b_android_deterministic_build,
  b_mac_deterministic_build,
  b_windows_deterministic_build,
  b_windows_clang_deterministic_build,
  b_android_deterministic_dbg_build,
  b_linux_deterministic_dbg_build,
  b_mac_deterministic_dbg_build,

  # Chromium DevTools
  b_chromium_devtools_linux,
]

c['builders'].extend([
  {
    'name': 'Linux remote_run Builder',
    'factory': m_remote_run('chromium', timeout=2400, max_time=10800),
    'category': 'remote_run',
    'auto_reboot': True,
  },
  {
    'name': 'Linux remote_run Tester',
    'factory': m_remote_run('chromium'),
    'category': 'remote_run',
    'auto_reboot': True,
  },
])

# Associate the slaves to the manual builders. The configuration is in
# slaves.cfg.
slaves = slaves_list.SlavesList('slaves.cfg', 'ChromiumFYI')
for builder in c['builders']:
  builder['slavenames'] = slaves.GetSlavesName(builder=builder['name'])


####### BUILDSLAVES

# The 'slaves' list defines the set of allowable buildslaves. List all the
# slaves registered to a builder. Remove dupes.
c['slaves'] = master_utils.AutoSetupSlaves(c['builders'],
                                           config.Master.GetBotPassword())

# Make sure everything works together.
master_utils.VerifySetup(c, slaves)


####### STATUS TARGETS

# Buildbot master url:
# Must come before AutoSetupMaster().
c['buildbotURL'] = ActiveMaster.buildbot_url

# Adds common status and tools to this master.
master_utils.AutoSetupMaster(
    c, ActiveMaster,
    public_html="../master.chromium/public_html",
    templates=['../master.chromium/templates'],
    enable_http_status_push=ActiveMaster.is_production_host,
    order_console_by_time=True)

# Add more.

if STATUS_PUSH:
  from buildbot.status.status_push import HttpStatusPush
  c['status'].append(HttpStatusPush(
      'http://craebuild.appspot.com/status-listener'))

c['status'].append(failures_notifier.FailuresNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='failing',
      categories=['goma'],
      relayhost=config.Master.smtp,
      subject='goma canary buildbot %(result)s in %(projectName)s '
              'on %(builder)s',
      extraRecipients=[
           'ukai@google.com',
           'yyanagisawa@google.com',
           'shinyak@google.com',
           'tikuta@google.com',
      ],
      sendToInterestedUsers=False,
      forgiving_steps=['diagnose_goma']))

c['status'].append(MailNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='failing',
      relayhost=config.Master.smtp,
      subject='Build failure on %(builder)s',
      extraRecipients=['chrome-pgo-build-failure@chromium.org',],
      sendToInterestedUsers=False,  # don't send e-mails to the committers.
      builders=[
          'Chromium Win PGO Builder',
          'Chromium Win x64 PGO Builder',
      ]))

c['status'].append(MailNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='failing',
      relayhost=config.Master.smtp,
      subject='Build failure on %(builder)s',
      extraRecipients=['sbc@chromium.org'],
      sendToInterestedUsers=False,
      builders=['Linux ARM']))
